package com.chuan.thinkingjava.lock;

/**
 *可重入锁 ReentrantLock, synchronized
 */
public class ReentrantLockTest {

    public static void main(String[] args) {
        RunnableTest runnableTest = new RunnableTest();
        for (;;) {
            new Thread(runnableTest).start();
        }
    }
}

class RunnableTest implements Runnable {

    @Override
    public void run() {
        testA();
    }


    synchronized void testA() {
        System.out.println("Thread is " + Thread.currentThread().getName() + " run testA.....");
        testB();
    }

    synchronized void testB() {
        System.out.println("Thread is " + Thread.currentThread().getName() + " run testB.....");
    }

}
